export function parseCommand(message: string): any {
  // 使用正则表达式提取命令和JSON数据
  const commandMatch = message.match(/```(\w+)/);
  const jsonMatch = message.match(/```[\s\S]*?```/);

  if (!commandMatch || !jsonMatch) {
    throw new Error("Invalid command format");
  }

  const command = commandMatch[1];
  // todo: 在jsonString中，移除以command开始的command的值
  const jsonString = jsonMatch[0]
    .replace(/```/g, "")
    .replace(new RegExp(`^${command}\\s*`, "g"), "")
    .trim();

  try {
    const parsedData = JSON.parse(jsonString);
    return {
      command,
      param: parsedData
    };
  } catch (error) {
    throw new Error("Failed to parse message");
  }
}
